package com.concerneyes.glasses;

import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.concerneyes.CEApp;
import com.concerneyes.R;

import common.AbsBaseView;
import common.BaseFragment;
import util.ImageUtil;

/**
 *产品图片轮播View
 */
@SuppressLint("ValidFragment")
public class GlassesViewPage extends AbsBaseView {
    private String imagepath;
    private ImageView iv_glasses;
    private RelativeLayout fl_glass;

    /**
     * 图片展示fragment
     *
     * @param context
     * @param imagepath 图片地址
     */
    public GlassesViewPage(Context context, String imagepath) {
        super(context);
        this.imagepath = imagepath;
        initViews();
    }


    public void initViews() {
        iv_glasses = (ImageView) findViewById(R.id.iv_glasses);
        fl_glass = (RelativeLayout) findViewById(R.id.fl_glass);
        initData();
    }

    @Override
    public int layoutResId() {
        return R.layout.view_glasses_fragment_item;
    }

    @Override
    public void loadData(Object data) {

    }

    @Override
    public boolean isEmpty() {
        return false;
    }

    public void initData() {
        setBackgroundColor(getResources().getColor(R.color.transparent));
        ViewGroup.LayoutParams lp = fl_glass.getLayoutParams();
        lp.width = getActivity().getResources().getDisplayMetrics().widthPixels / 2;
        double height = getActivity().getResources().getDisplayMetrics().heightPixels * 0.28;
        lp.height = (int) height;
        fl_glass.setLayoutParams(lp);
        String resLink = CEApp.getResLink(imagepath);
        ImageUtil.glideloadImage(resLink, iv_glasses, R.drawable.default_header);
    }


}